package com.xwx.common.model;
import java.util.ArrayList;
import java.util.List;

import com.xwx.common.utils.Condition;


/**
 * 单位
* @Description:TODO  
* @author:Dream QQ:68697015
* @time:2015年8月7日 下午5:02:19
 */

@SuppressWarnings("serial")
public class DepModel extends ModelExt<DepModel>{
	public static final DepModel dao = new DepModel();
	/**
	 * 根据上级编号查询部门
	 * @param pId 0取顶级
	 * @return
	 */
	public static List<DepModel> queryListByPid(Object pId){
		return dao.queryListByCondition(new Condition().eq("pId", pId).toString());
		
	}
	/**
	 * 查询某部门下的所有用户
	 * @param depId
	 * @return
	 */
	public static List<UserModel> queryUserByDep(String depId){
		List<UserModel> list = new ArrayList<UserModel>();
		List<UserDepModel> udmList=UserDepModel.dao.queryListByCondition(new Condition().eq("depId", depId).toString());
		for (UserDepModel udm : udmList) {
			list.add(UserModel.dao.queryById(udm.get("userId")));
		}
		return list;
	}
	/**
	 * 根据单位编号获取单位扩展
	 * @param depId
	 * @return
	 */
	public static DepExtModel queryDepExt(String depId){
		return DepExtModel.dao.queryByCondition(new Condition().eq("depId", depId).toString());
	}
}
